package com.dragon.design.pattern.creational.singleton;

/**
 * 懒加载双重检查
 *
 * @author dragon
 * @version V1.0.0-RELEASE
 * @date 2019/5/15 19:58
 */
public class LazyDoubleCheckSingleton {

    private volatile static LazyDoubleCheckSingleton lazyDoubleCheckSingleton = null;

    private LazyDoubleCheckSingleton() {

    }

    /**
     * double check 双重检查,为了解决多线程中的安全隐患
     *
     * @param
     * @return com.dragon.design.pattern.creational.singleton.LazyDoubleCheckSingleton
     * @author dragon
     * @date 2019/5/15 20:00
     * @version V1.0.0-RELEASE
     */
    public static LazyDoubleCheckSingleton getInstance() {
        if (lazyDoubleCheckSingleton == null) {
            synchronized (LazyDoubleCheckSingleton.class) {
                if (lazyDoubleCheckSingleton == null) {
                    lazyDoubleCheckSingleton = new LazyDoubleCheckSingleton();
                }
            }
        }

        return lazyDoubleCheckSingleton;
    }
}
